﻿Public Class PasswordForm

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Me.TextBox1.Text.Trim = "" Then
            ShowMessageBox("密码不能为空")
            TextBox1.Focus()
            Exit Sub
        End If

        'If Me.TextBox1.Text.Trim.ToLower <> "wysjcy" Then
        '    ShowMessageBox("密码不正确")
        '    TextBox1.Text = ""
        '    TextBox1.Focus()
        '    Exit Sub
        'End If
        Dim sql As String = "select * from XSCPWD where PWD=?"
        Dim CMD As New ADODB.Command
        CMD.CommandText = sql
        Dim pa As ADODB.Parameter = CMD.CreateParameter(, ADODB.DataTypeEnum.adWChar, ADODB.ParameterDirectionEnum.adParamInput, 50)
        pa.Value = Me.TextBox1.Text.Trim
        CMD.Parameters.Append(pa)

        Dim rs As ADODB.Recordset = ct.ExcCommandAsRs(CMD)
        If rs Is Nothing Then
            ShowMessageBox("密码不正确")
            TextBox1.Text = ""
            TextBox1.Focus()
            Exit Sub
        End If

        If rs.EOF Then
            rs.Close()
            System.Runtime.InteropServices.Marshal.ReleaseComObject(rs)
            ShowMessageBox("密码不正确")

            TextBox1.Text = ""
            TextBox1.Focus()
            Exit Sub
        End If

        rs.Close()
        System.Runtime.InteropServices.Marshal.ReleaseComObject(rs)
        DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub


End Class
